package com.jxj.controller;

import com.jxj.entity.Resp;
import com.jxj.util.GetSocMapping;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Slf4j
public class SocMapController {
    @GetMapping("/getnum")
    public Resp getSocId(String name)
    {
        log.info("\n------\nselect id of {}\n------\n" , name);
        if (name.isEmpty()) {
            return new Resp(HttpStatus.BAD_REQUEST , null);
        }
        Map<Integer, String> map = GetSocMapping.getMap();
        for (Map.Entry<Integer, String> entry : map.entrySet()) {
            if (entry.getValue() .equals(name))
            return new Resp(HttpStatus.OK, entry.getKey());
        }
        return new Resp(HttpStatus.BAD_REQUEST, "无此社团",null);
    }
}
